﻿Type=Activity
Version=6
ModulesStructureVersion=1
B4A=true
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: False
#End Region

Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.

End Sub

Sub Globals
	'These global variables will be redeclared each time the activity is created.
	'These variables can only be accessed from this module.

	Private lblselected As Label
	Private pclientmobile As Panel
	Private edtyzm As EditText
	Private edtmobilephone As EditText
	Private btngetyzm As Button
	Private rbnan As RadioButton
	Private rbnv As RadioButton
	Private rbnolimit As RadioButton
	Private rbadrother As RadioButton
	Private rbadrtea As RadioButton
	Private rbadrstu As RadioButton
	Dim mi As myInfo
	Dim mReq As Map
	Private tmr As Timer 'yzm
	Dim nptr As Int
	Private btnleft As Label
	Private edtrealname As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
Dim telaw As telanywhere
telaw.Initialize(Activity)

	'Do not forget to load the layout file created with the visual designer. For example:
	Activity.LoadLayout("layhelpyoufindteacher")
	comm.aio(Activity)
	initviews
End Sub
Sub initviews
	If g_store.getDef("islogin",False) Then
'		pclientmobile.Visible=False
		mi=g_store.get("myinfo")
		edtyzm.Enabled=False
		edtyzm.Text="已登录无需验证码"
		btngetyzm.Enabled=False
		edtmobilephone.Text=mi.usertel.Trim
		edtmobilephone.Enabled=False
	End If
	comm.setFA(btnleft,"fa-angle-left","")
	mReq.Initialize
	mReq.Put("sex",1)
	mReq.Put("sk_type","老师上门")
End Sub
Sub Activity_Resume

End Sub
Sub nosub
	
End Sub
Sub gotRec(s As String,g As String)
	lblselected.Text="已选择 "&s&" "&g
	mReq.Put("kemu",s)
	mReq.Put("nianji",g)
End Sub
Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub lblselected_Click
	StartActivity(actselectsubjectgrade)
End Sub
Private Sub reqSmsCode(mobile As String)
	ProgressDialogShow("正在获取验证码")
	ParseHelper.doGetReq(Me,"sms",comm.getApi(comm.apiIdx.REQSMS),Array As String("usertel",mobile))
End Sub
Sub JobDone(thj As HttpJob)
	ProgressDialogHide
	If thj.Success Then
		Dim str As String=thj.GetString
		Log(str)
		Dim nr As netRes=ParseHelper.getStatusData(str)
		If nr.nCode=200 Then
			Select thj.JobName
			Case "sms"
				comm.TL("验证码获取成功")
				nptr=60
				tmr.Initialize("tmr",1000)
				tmr.Enabled=True
			Case "subhelperord"
				comm.TL("提交成功")
				Activity.Finish
'				'短信登录
'				'更新cookie
'				Log(str)
'				ParseHelper.updateCookie(thj.GetHeader)
'				ParseHelper.parseMyInfo(str)
'				g_store.conf.Put("islogin",True)
'				CallSubDelayed(actmain,"fillmyinfo")
'				Activity.Finish
			End Select
		Else
			comm.TL(thj.JobName&"错误:"&nr.sData)
		End If
	Else
		comm.TL("网络错误:"&thj.JobName&" "&thj.ErrorMessage)
	End If
	thj.Release
End Sub
Sub btnFindTeacher_Click
	If mi.IsInitialized=False Then
		If edtmobilephone.Text.Trim.Length<10 Then
			comm.TL("请先输入手机号并获取验证码")
			Return
		End If
		If edtyzm.Text.Trim.Length<1 Then
			comm.TL("请先获取验证码")
			Return
		End If
		If edtrealname.Text.Trim.Length<1 Then
			comm.TL("请输入您的姓名方便我们联系您")
			Return
		End If
		Dim nj As String=mReq.GetDefault("kemu","")
		If nj.Length<1 Then
			comm.TL("请先选择好您的科目和年级")
			Return
		End If
		mReq.Put("sms_code",edtyzm.Text.Trim)
		mReq.Put("usertel",edtmobilephone.Text.Trim)
		mReq.Put("realname",edtrealname.Text.Trim)
	Else
		mReq.Put("usertel",mi.usertel)
		mReq.Put("sms_code","666666")
		mReq.Put("realname",edtrealname.Text.Trim)
	End If
	comm.showProgress("正在提交订单")
	ParseHelper.doPostReqMap(Me,"subhelperord",comm.getApi(comm.apiIdx.REQHELPYOUFINDTEACHER),mReq,"")
End Sub
Sub tmr_Tick
	If nptr>0 Then
		nptr=nptr-1
		btngetyzm.Enabled=False
		btngetyzm.Text=nptr
		btngetyzm.TextColor=Colors.Black
	Else
		btngetyzm.Enabled=True
		btngetyzm.Text="获取验证码"
		btngetyzm.TextColor=Colors.White
		tmr.Enabled=False
	End If
End Sub
Sub btngetyzm_Click
	If edtmobilephone.Text.Trim.Length<>11 Then
		comm.T("手机号码不正确")
	Else
		reqSmsCode(edtmobilephone.Text.Trim)
	End If
End Sub

Sub btnleft_Click
	Activity.Finish
End Sub

Sub rbnan_CheckedChange(Checked As Boolean)
	If Checked Then mReq.Put("sex",1)
End Sub

Sub rbnv_CheckedChange(Checked As Boolean)
	If Checked Then mReq.Put("sex",2)
End Sub

Sub rbnolimit_CheckedChange(Checked As Boolean)
	If Checked Then mReq.Put("sex",0)
End Sub

Sub rbadrstu_CheckedChange(Checked As Boolean)
	If Checked Then mReq.Put("sk_type","老师上门")
End Sub

Sub rbadrtea_CheckedChange(Checked As Boolean)
	If Checked Then mReq.Put("sk_type","学生上门")
End Sub

Sub rbadrother_CheckedChange(Checked As Boolean)
	If Checked Then mReq.Put("sk_type","协商地址")
End Sub